﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using System.Data;

namespace NJL.Web
{
    public partial class NewsShow : BasePageVisitor
    {

        private readonly BLL.NJL_SYS_NEWS bllNews = new BLL.NJL_SYS_NEWS();
        private readonly BLL.NJL_SYS_CS_NEWS_TYPE bllNewsType = new BLL.NJL_SYS_CS_NEWS_TYPE();
        protected IList<Model.NJL_SYS_CS_NEWS_TYPE> LIST_NEWS_TYPE;
        protected string NEWS_TYPE_CODE;
        protected string NEWS_TYPE_NAME;

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadData();
            if (!IsPostBack)
            {
                bind();
            }
            base.LoadPageSeoInformation(NEWS_TYPE_NAME);
        }

        private void LoadData()
        {
            if (Request.QueryString["id"] == null || Request.QueryString["id"] == "")
            {
                Response.Redirect("/Default.aspx", true);
            }
            NEWS_TYPE_CODE = Request.QueryString["id"];
            NEWS_TYPE_NAME = bllNewsType.GetModel(NEWS_TYPE_CODE).TYPE_NAME;
            LIST_NEWS_TYPE = bllNewsType.GetModelList(" TYPE_CODE>20");

        }
        string url = "";
        public void bind()
        {
            switch (Request.QueryString["id"])
            {
                case "18":
                    url = "/jdms/jdgz/";
                    break;
                case "17":
                    url = "/dfts/dfts/";
                    break;
                case "16":
                    url = "/djsz/xinwen/"; 
                    break;
                case "39":
                    url = "/djsz/huiyi/";
                    break;
                case "19":
                    url = "/njxy/njzx/";
                    break;
            }
            DataSet ds = bllNews.GetList("a.TYPE_CODE='" + NEWS_TYPE_CODE + "' and NJL_SYS_BASE_ID='"+WEBSITE_CODE+"'");
            if (ds.Tables[0].Rows.Count > 15)
            {
                string[] param = new string[] { "id" };
                pager.InnerHtml = Royalsoft.Common.Pager.GetPageNum(ds, rptUserList, 15, param,url);
            }
            else
            {
                rptUserList.DataSource = ds;
                rptUserList.DataBind();
            }

        }

        protected void rptUserList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Literal litUrl = e.Item.FindControl("litUrl") as Literal;
                Literal Literal1 = e.Item.FindControl("Literal1") as Literal;
                DataRowView drv = (DataRowView)e.Item.DataItem;
                string typecode = drv["TYPE_CODE"].ToString();
                switch (typecode)
                {
                    case "18":
                        litUrl.Text = "/jdms/jdgz/";
                        Literal1.Text = "/jdms/jdgz/";
                        break;
                    case "17":
                        litUrl.Text = "/dfts/dfts/";
                        Literal1.Text = "/dfts/dfts/";
                        break;
                    case "16":
                        litUrl.Text = "/djsz/xinwen/";
                        Literal1.Text = "/djsz/xinwen/";
                        break;
                    case "39":
                        litUrl.Text = "/djsz/huiyi/";
                        Literal1.Text = "/djsz/huiyi/";
                        break;
                    case "19":
                        litUrl.Text = "/njxy/njzx/";
                        Literal1.Text = "/njxy/njzx/";
                        break;
                }
            }
        }



    }
}